package main

import (
	"flag"
	"github.com/GoDistributedCacheFramework/src/cache"
	"github.com/GoDistributedCacheFramework/src/cluster"
	"github.com/GoDistributedCacheFramework/src/http"
	"github.com/GoDistributedCacheFramework/src/tcp"
	"log"
)

func main()  {
	// 存储类型，缓存nmemory,磁盘存储rocksdb
	typ := flag.String("type","inmemory","cache type")
	// 缓存中值过期时间，过期后，值会失效并被清除
	ttl := flag.Int("ttl",30,"cache time to live")
	// 本节点地址，
	node := flag.String("node","127.0.0.1","node address")
	// 需要加入的集群某个节点的地址
	clus := flag.String("cluster","","cluster address")
	flag.Parse()
	log.Println("type is",*typ)
	log.Println("ttl is",*ttl)
	log.Println("node is",*node)
	log.Println("cluster is",*clus)
	c := cache.New(*typ,*ttl)
	n,e := cluster.New(*node,*clus)
	if e != nil {
		panic(e)
	}
	// tcp 实现
	go tcp.New(c,n).Listen()
	// http 实现
	http.New(c,n).Listen()


}



